package com.kukudexin.handle;

import cn.afterturn.easypoi.handler.inter.IExcelDictHandler;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

/**
 * @author: 酷酷的鑫
 * @Date: 2021/9/17 10:26
 * @description:
 */
public class GlobalExcelDictHandler implements IExcelDictHandler {
    @Override
    public String toName(String dict, Object obj, String name, Object value) {
        return getDictCache(dict).get(value);
    }

    @Override
    public String toValue(String dict, Object obj, String name, Object value) {
        return getDictCache(dict).inverse().get(name);
    }

    public BiMap<String,String> getDictCache(String catalog){
        BiMap<String,String> weekNameMap = HashBiMap.create();
        if(catalog.equals("aDict")) {
            weekNameMap.put("01A","代码01A");
            weekNameMap.put("02A","代码02A");
        }else if(catalog.equals("bDict")) {
            weekNameMap.put("01B","代码01B");
            weekNameMap.put("02B","代码02B");
        }
        return weekNameMap;
    }
}
